package com.bdqn.vueboot;

import com.bdqn.vueboot.util.RedisUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@SpringBootTest
@RunWith(SpringRunner.class)
public class RedisTemplateTester {

    @Resource
    RedisUtil redisUtil;

    @Resource
    private StringRedisTemplate stringRedisTemplate; //操作字符串数据
    @Resource
    private RedisTemplate redisTemplate; //操作其他数据类型

    @Test
    public void testStringTester() {
        stringRedisTemplate.opsForValue().set("name1", "czkt", 150, TimeUnit.SECONDS);
    }

    @Test
    public void getStringTester() {
        String czkt = stringRedisTemplate.opsForValue().get("name");
        System.out.println(czkt);
    }

    @Test
    public void deleteStringTester() {
        Boolean bool = stringRedisTemplate.delete("name");
        System.out.println(bool);
    }

    @Test
    public void addTest() {
        redisUtil.set("aac", "bb");
    }

    @Test
    public void getTest() {
        Object obj = redisUtil.get("4d12b188-5c9c-4e94-9755-222ced4278a5");
        System.out.println(obj);
    }
}